#ifndef _IFAPP_CLI_H
#define _IFAPP_CLI_H
#ifndef EUTRAN_PLATFORM
#define EUTRAN_PLATFORM
#endif
#define CLI_TCP_CONN_TIMEOUT				5

//#define CLI_TO_AUTH_ALL						0x80000000
#define CLI_TO_MNG_ALL						0x40000000
#define CLI_TO_DATA_ALL						0x20000000
#define CLI_TO_SRV_ALL_MASK					0xF0000000
#define CLI_TO_FD_MASK						0x0FFFFFFF

#define MNG_SERVER_STATUS_DISCONNECTED		7
#define MNG_SERVER_STATUS_WAITING_WELCOME	8
#define MNG_SERVER_STATUS_CONNECTING		9
#define MNG_SERVER_STATUS_CONNECTED			10

#define DATA_SERVER_STATUS_DISCONNECTED		11
#define DATA_SERVER_STATUS_WAITING_WELCOME	12
#define DATA_SERVER_STATUS_CONNECTING		13
#define DATA_SERVER_STATUS_CONNECTED		14

#define CLI_THREAD_DESTORIED				15
#define CLI_THREAD_CREATING					16
#define CLI_THREAD_CREATED					17
#define CLI_INIT_AUTH                       18
#define CLI_INIT_DONE						19
#define CLI_INIT_MNG                        20
#define CLI_INIT_DATA                       21



//#define CLI_SRV_AUTH						0x0000
#define CLI_SRV_DATA						0x1000
#define CLI_SRV_MNG							0x2000

//#define CLI_SOCK_ERR_AUTH					0x0000
#define CLI_SOCK_ERR_DATA					0x1000
#define CLI_SOCK_ERR_MNG					0x2000
#define CLI_SOCK_ERR_SELECT					0x3000

#define CLI_SOCK_CONNECT_REFUSED            0x4000
#define CLI_SOCK_MNG_REFUSED                0x4001
#define CLI_SOCK_DATA_REFUSED               0x4002

//I32 cli_create_tcp_socket(I32 srv, I8 * addr, I32 port);
I32 cli_destroy_tcp_socket(I32 fd);

I32 cli_send_to_tcp(I32 fd, I8 * data, I32 len, I32 send_skey);

I32 send_imsi_data(bool isMng, I8 * record, I8 *buf);

I32 cli_send_to_data(I8 * data, I32 len);
I32 cli_send_to_mng(I8 * data, I32 len);
I32 cli_init(DEV_CONF * conf, U32 step);
I32 cli_exit(void);
I8 *get_host_by_server(I8 *server);
__inline I32 cli_get_mng_status(void);
__inline I32 cli_set_mng_status(I32 status);
__inline I32 cli_get_data_status(void);
__inline I32 cli_set_data_status(I32 status);
__inline bool GetCliThreadStat();
I32 sendHeartBeat(I32 port, const I8 *buf, I32 bufLen);
I32 sendBaiZhuoHb();
I32 sendDataByUdp(I8 *imsi, I8 *imei, I8 *time);
void sendMacDataByUdp(I8 *mac, I8* time);
I32 initUdpthread();
#ifdef MODULE_TEST
void setTestCliThread();
#endif

I32 cli_sock_is_data(I32 sock);
I32 cli_sock_is_mng(I32 sock);
I32  getSock(bool isMng);
#ifdef IF_APP_UNIT_TEST
void cli_set_fd_to_stdout(void);
I32 cli_gen_test_ctrl_string(I8 * buf, I32 code);
#endif

#endif
